package com.medic.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.medic.entity.group.pain.Plan;
import com.medic.mapper.interf.PlanMapper;
import com.medic.service.interf.PlanServiceInterface;

/**
 * 服药计划业务类
 * 
 * @author Mr.zhang
 *
 */
@Service("planService")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // 注明需要回滚
public class PlanServiceImpl implements PlanServiceInterface {

	@Autowired
	private PlanMapper planMapper;

	@Override
	public boolean save(Plan object) throws Exception {
		boolean result = false;
		if (planMapper.save(object) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean delete(Plan object) throws Exception {
		boolean result = false;
		if (planMapper.delete(object) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean update(Plan object) throws Exception {
		boolean result = false;
		if (planMapper.update(object) > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public Plan getById(int planId) throws Exception {
		return planMapper.selectById(planId);
	}

	@Override
	public Plan getByGroupId(int groupId) throws Exception {
		return planMapper.selectByGroupId(groupId);
	}
}
